﻿using System;
using System.Data;
using System.Collections.Generic;
using Maticsoft.Common;
using Golf.Model;
namespace Golf.BLL
{
	/// <summary>
	/// Golf_RefundType
	/// </summary>
	public partial class Golf_RefundType
	{
		private readonly Golf.DAL.Golf_RefundType dal=new Golf.DAL.Golf_RefundType();
		public Golf_RefundType()
		{}
		#region  Method

		/// <summary>
		/// 得到最大ID
		/// </summary>
		public int GetMaxId()
		{
			return dal.GetMaxId();
		}

		/// <summary>
		/// 是否存在该记录
		/// </summary>
		public bool Exists(int Id)
		{
			return dal.Exists(Id);
		}

		/// <summary>
		/// 增加一条数据
		/// </summary>
		public int  Add(Golf.Model.Golf_RefundType model)
		{
			return dal.Add(model);
		}

		/// <summary>
		/// 更新一条数据
		/// </summary>
		public bool Update(Golf.Model.Golf_RefundType model)
		{
			return dal.Update(model);
		}

		/// <summary>
		/// 删除一条数据
		/// </summary>
		public bool Delete(int Id)
		{
			
			return dal.Delete(Id);
		}
		/// <summary>
		/// 删除一条数据
		/// </summary>
		public bool DeleteList(string Idlist )
		{
			return dal.DeleteList(Idlist );
		}

		/// <summary>
		/// 得到一个对象实体
		/// </summary>
		public Golf.Model.Golf_RefundType GetModel(int Id)
		{
			
			return dal.GetModel(Id);
		}

		/// <summary>
		/// 得到一个对象实体，从缓存中
		/// </summary>
		public Golf.Model.Golf_RefundType GetModelByCache(int Id)
		{
			
			string CacheKey = "Golf_RefundTypeModel-" + Id;
			object objModel = Maticsoft.Common.DataCache.GetCache(CacheKey);
			if (objModel == null)
			{
				try
				{
					objModel = dal.GetModel(Id);
					if (objModel != null)
					{
						int ModelCache = Maticsoft.Common.ConfigHelper.GetConfigInt("ModelCache");
						Maticsoft.Common.DataCache.SetCache(CacheKey, objModel, DateTime.Now.AddMinutes(ModelCache), TimeSpan.Zero);
					}
				}
				catch{}
			}
			return (Golf.Model.Golf_RefundType)objModel;
		}

		/// <summary>
		/// 获得数据列表
		/// </summary>
		public DataSet GetList(string strWhere)
		{
			return dal.GetList(strWhere);
		}
		/// <summary>
		/// 获得前几行数据
		/// </summary>
		public DataSet GetList(int Top,string strWhere,string filedOrder)
		{
			return dal.GetList(Top,strWhere,filedOrder);
		}
		/// <summary>
		/// 获得数据列表
		/// </summary>
		public List<Golf.Model.Golf_RefundType> GetModelList(string strWhere)
		{
			DataSet ds = dal.GetList(strWhere);
			return DataTableToList(ds.Tables[0]);
		}
		/// <summary>
		/// 获得数据列表
		/// </summary>
		public List<Golf.Model.Golf_RefundType> DataTableToList(DataTable dt)
		{
			List<Golf.Model.Golf_RefundType> modelList = new List<Golf.Model.Golf_RefundType>();
			int rowsCount = dt.Rows.Count;
			if (rowsCount > 0)
			{
				Golf.Model.Golf_RefundType model;
				for (int n = 0; n < rowsCount; n++)
				{
					model = new Golf.Model.Golf_RefundType();
					if(dt.Rows[n]["Id"]!=null && dt.Rows[n]["Id"].ToString()!="")
					{
						model.Id=int.Parse(dt.Rows[n]["Id"].ToString());
					}
					if(dt.Rows[n]["OrderId"]!=null && dt.Rows[n]["OrderId"].ToString()!="")
					{
						model.OrderId=int.Parse(dt.Rows[n]["OrderId"].ToString());
					}
					if(dt.Rows[n]["OrderNumber"]!=null && dt.Rows[n]["OrderNumber"].ToString()!="")
					{
					model.OrderNumber=dt.Rows[n]["OrderNumber"].ToString();
					}
					if(dt.Rows[n]["RefundType"]!=null && dt.Rows[n]["RefundType"].ToString()!="")
					{
						model.RefundType=int.Parse(dt.Rows[n]["RefundType"].ToString());
					}
					if(dt.Rows[n]["RefundPrice"]!=null && dt.Rows[n]["RefundPrice"].ToString()!="")
					{
						model.RefundPrice=decimal.Parse(dt.Rows[n]["RefundPrice"].ToString());
					}
					if(dt.Rows[n]["RefundTime"]!=null && dt.Rows[n]["RefundTime"].ToString()!="")
					{
						model.RefundTime=DateTime.Parse(dt.Rows[n]["RefundTime"].ToString());
					}
					if(dt.Rows[n]["IsState"]!=null && dt.Rows[n]["IsState"].ToString()!="")
					{
						if((dt.Rows[n]["IsState"].ToString()=="1")||(dt.Rows[n]["IsState"].ToString().ToLower()=="true"))
						{
						model.IsState=true;
						}
						else
						{
							model.IsState=false;
						}
					}
					if(dt.Rows[n]["AdminId"]!=null && dt.Rows[n]["AdminId"].ToString()!="")
					{
						model.AdminId=int.Parse(dt.Rows[n]["AdminId"].ToString());
					}
					if(dt.Rows[n]["AddTime"]!=null && dt.Rows[n]["AddTime"].ToString()!="")
					{
						model.AddTime=DateTime.Parse(dt.Rows[n]["AddTime"].ToString());
					}
					modelList.Add(model);
				}
			}
			return modelList;
		}

		/// <summary>
		/// 获得数据列表
		/// </summary>
		public DataSet GetAllList()
		{
			return GetList("");
		}

		/// <summary>
		/// 分页获取数据列表
		/// </summary>
        public DataSet GetList(int PageSize, int PageIndex, string strWhere)
        {
            return dal.GetList(PageSize, PageIndex, strWhere);
        }

		#endregion  Method
	}
}

